<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .ad{
            width: 300px;
            height: 300px;
            background: red;
            color: white;
        }
    </style>
</head>
<body>
    <div class="ad">
        <p><span class="close">X</span></p>
    </div>
    <script>
        // 获取元素 ；
        var closeEle = document.getElementsByClassName("close")[0];
        var adEle = document.getElementsByClassName("ad")[0];
        closeEle.onclick = function(){
            adEle.style.display = "none";
            setTimeout(function(){
                adEle.style.display = "block";
            },2000);
        }

    </script>
</body>
</html>